<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/login.css">
<body>
    <!-- <form action="loginDone" method="post">
        用户名：<input type="text" name="uid">
        <br />
        密 码：<input type="password" name="pwd">
        <br />
        <br />
        <input type="submit" value="登录">
        <button id="register" value="注册"></button> 
      <a href="./register"> <input type="button" value="注册"> </a> 
    </form> -->

    <div class="card">
        <!-- <img src="..." class="card-img-top" alt="..."> -->
        <h5 class="card-header">登录界面</h5>
        <div class="card-body">
            <form id="loginForm" action="/loginDone" method="POST">
                <div class="form-group">
                  <label for="exampleInputEmail1">用户名：</label>
                  <input type="text" name="username" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
                </div>
                <div class="form-group">
                  <label for="exampleInputPassword1">密码：</label>
                  <input type="password" name="password" class="form-control" id="exampleInputPassword1">
                  <!-- <small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small> -->
                </div>
                <div class="form-group form-check">
                  <input type="checkbox" class="form-check-input" id="exampleCheck1">
                  <label class="form-check-label" for="exampleCheck1">记住我</label>
                </div>
                <div class="col">
                  <div class="alert alert-danger alert-dismissible fade show invisible text-center" style="width: 42rem;"
                      role="alert">
                      <strong>提示：</strong><label for="" id="msg">555</label>
                      <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                          <span aria-hidden="true">&times;</span>
                      </button>
                  </div>
              </div>
                <br />
                <button type="submit" class="btn btn-primary" >登录</button>
                <button type="button" class="btn btn-primary" onclick="run()">注册</button>
              </form>
        </div>
      </div>
      <link rel="stylesheet" href="/js/jquery-3.6.0.min.js">
      <link rel="stylesheet" href="/js/bootstrap.min.js">
      <script>
        function run(){
          window.location.href='register';
        };

        // function logic(){
        //   let username = $('#username').val();
        //   let password = $('#password').val();

        //   if(username.length > 0 && password.length > 0){
        //     $.ajax({
        //             url: "/loginDone",
        //             type: "POST",
        //             data: $('#loginForm').serialize(),
        //             dataType: "json",
        //             success: function (res) {
        //                 console.log(res);
        //                 if(res.code===200){
        //                     window.location.href="/";
        //                 }else{
        //                     alert_fn(res.msg);
        //                 }
        //             },
        //             error: function (msg) {
        //                 alert_fn('网络或者服务器有问题');
        //             }
        //         })
        //   }else{
        //     alert_fn('用户名或密码不能为空');
        //     return false;
        //   }
        // }

        // function alert_fn(msg){
        //   msg = msg || '密码不能为空';
        //   $('#msg').text(msg);
        //   $('.invisible').removeClass('invisible');
        //   setTimeout(()=>{
        //     $('.alert').addClass('invisible');
        //   },5000)
        // }
      </script>
</body>
</html>